home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Game Programming Gurus / Tricks of the Windows Game Programming Gurus (SAMS)(2000).iso / Goodies / t3dlib1.h < prev    next >
C/C++ Source or Header  |  1999-08-31  |  20KB  |  474 lines

  1. // T3DLIB1.H - Header file for T3DLIB1.CPP game engine library
  2.  
  3. // watch for multiple inclusions
  4. #ifndef T3DLIB1
  5. #define T3DLIB1
  6.  
  7. // DEFINES ////////////////////////////////////////////////
  8.  
  9. // default screen values, these are all overriden by the 
  10. // call to DDraw_Init() and are just here to have something
  11. // to set the globals to instead of constant values
  12. #define SCREEN_WIDTH        640  // size of screen
  13. #define SCREEN_HEIGHT       480
  14. #define SCREEN_BPP          8    // bits per pixel
  15. #define MAX_COLORS_PALETTE  256
  16.  
  17.  
  18. #define DEFAULT_PALETTE_FILE "PALDATA2.PAL"
  19.  
  20. // used for selecting full screen/windowed mode
  21. #define SCREEN_FULLSCREEN    0
  22. #define SCREEN_WINDOWED      1
  23.  
  24. // bitmap defines
  25. #define BITMAP_ID            0x4D42 // universal id for a bitmap
  26. #define BITMAP_STATE_DEAD    0
  27. #define BITMAP_STATE_ALIVE   1
  28. #define BITMAP_STATE_DYING   2 
  29. #define BITMAP_ATTR_LOADED   128
  30.  
  31. #define BITMAP_EXTRACT_MODE_CELL  0
  32. #define BITMAP_EXTRACT_MODE_ABS   1
  33.  
  34. // directdraw pixel format defines, used to help
  35. // bitmap loader put data in proper format
  36. #define DD_PIXEL_FORMAT8        8
  37. #define DD_PIXEL_FORMAT555      15
  38. #define DD_PIXEL_FORMAT565      16
  39. #define DD_PIXEL_FORMAT888      24
  40. #define DD_PIXEL_FORMATALPHA888 32 
  41.  
  42.  
  43. // defines for BOBs
  44. #define BOB_STATE_DEAD         0    // this is a dead bob
  45. #define BOB_STATE_ALIVE        1    // this is a live bob
  46. #define BOB_STATE_DYING        2    // this bob is dying
  47. #define BOB_STATE_ANIM_DONE    1    // done animation state
  48. #define MAX_BOB_FRAMES         64   // maximum number of bob frames
  49. #define MAX_BOB_ANIMATIONS     16   // maximum number of animation sequeces
  50.  
  51. #define BOB_ATTR_SINGLE_FRAME   1   // bob has single frame
  52. #define BOB_ATTR_MULTI_FRAME    2   // bob has multiple frames
  53. #define BOB_ATTR_MULTI_ANIM     4   // bob has multiple animations
  54. #define BOB_ATTR_ANIM_ONE_SHOT  8   // bob will perform the animation once
  55. #define BOB_ATTR_VISIBLE        16  // bob is visible
  56. #define BOB_ATTR_BOUNCE         32  // bob bounces off edges
  57. #define BOB_ATTR_WRAPAROUND     64  // bob wraps around edges
  58. #define BOB_ATTR_LOADED         128 // the bob has been loaded
  59. #define BOB_ATTR_CLONE          256 // the bob is a clone
  60.  
  61. // screen transition commands
  62. #define SCREEN_DARKNESS  0         // fade to black
  63. #define SCREEN_WHITENESS 1         // fade to white
  64. #define SCREEN_SWIPE_X   2         // do a horizontal swipe
  65. #define SCREEN_SWIPE_Y   3         // do a vertical swipe
  66. #define SCREEN_DISOLVE   4         // a pixel disolve
  67. #define SCREEN_SCRUNCH   5         // a square compression
  68. #define SCREEN_BLUENESS  6         // fade to blue
  69. #define SCREEN_REDNESS   7         // fade to red
  70. #define SCREEN_GREENNESS 8         // fade to green
  71.  
  72. // defines for Blink_Colors
  73. #define BLINKER_ADD           0    // add a light to database  
  74. #define BLINKER_DELETE        1    // delete a light from database
  75. #define BLINKER_UPDATE        2    // update a light
  76. #define BLINKER_RUN           3    // run normal
  77.  
  78. const double PI = 3.1415926535;
  79.  
  80. // fixed point mathematics constants
  81. #define FIXP16_SHIFT     16
  82. #define FIXP16_MAG       65536
  83. #define FIXP16_DP_MASK   0x0000ffff
  84. #define FIXP16_WP_MASK   0xffff0000
  85. #define FIXP16_ROUND_UP  0x00008000
  86.  
  87. // MACROS /////////////////////////////////////////////////
  88.  
  89. // these read the keyboard asynchronously
  90. #define KEY_DOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
  91. #define KEY_UP(vk_code)   ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1)
  92.  
  93. // this builds a 16 bit color value in 5.5.5 format (1-bit alpha mode)
  94. #define _RGB16BIT555(r,g,b) ((b & 31) + ((g & 31) << 5) + ((r & 31) << 10))
  95.  
  96. // this builds a 16 bit color value in 5.6.5 format (green dominate mode)
  97. #define _RGB16BIT565(r,g,b) ((b & 31) + ((g & 63) << 6) + ((r & 31) << 11))
  98.  
  99. // bit manipulation macros
  100. #define SET_BIT(word,bit_flag)   ((word)=((word) | (bit_flag)))
  101. #define RESET_BIT(word,bit_flag) ((word)=((word) & (~bit_flag)))
  102.  
  103. // initializes a direct draw struct, basically zeros it and sets the dwSize field
  104. #define DDRAW_INIT_STRUCT(ddstruct) { memset(&ddstruct,0,sizeof(ddstruct)); ddstruct.dwSize=sizeof(ddstruct); }
  105.  
  106. // used to compute the min and max of two expresions
  107. #define MIN(a, b)  (((a) < (b)) ? (a) : (b)) 
  108. #define MAX(a, b)  (((a) > (b)) ? (b) : (a)) 
  109.  
  110. // used for swapping algorithm
  111. #define SWAP(a,b,t) {t=a; a=b; b=t;}
  112.  
  113. // some math macros
  114. #define DEG_TO_RAD(ang) ((ang)*PI/180)
  115. #define RAD_TO_DEG(rads) ((rads)*180/PI)
  116.  
  117. // TYPES //////////////////////////////////////////////////
  118.  
  119. // basic unsigned types
  120. typedef unsigned short USHORT;
  121. typedef unsigned short WORD;
  122. typedef unsigned char  UCHAR;
  123. typedef unsigned char  BYTE;
  124. typedef unsigned int   QUAD;
  125. typedef unsigned int   UINT;
  126.  
  127. // container structure for bitmaps .BMP file
  128. typedef struct BITMAP_FILE_TAG
  129.         {
  130.         BITMAPFILEHEADER bitmapfileheader;  // this contains the bitmapfile header
  131.         BITMAPINFOHEADER bitmapinfoheader;  // this is all the info including the palette
  132.         PALETTEENTRY     palette[256];      // we will store the palette here
  133.         UCHAR            *buffer;           // this is a pointer to the data
  134.  
  135.         } BITMAP_FILE, *BITMAP_FILE_PTR;
  136.  
  137. // the blitter object structure BOB
  138. typedef struct BOB_TYP
  139.         {
  140.         int state;          // the state of the object (general)
  141.         int anim_state;     // an animation state variable, up to you
  142.         int attr;           // attributes pertaining to the object (general)
  143.         int x,y;            // position bitmap will be displayed at
  144.         int xv,yv;          // velocity of object
  145.         int width, height;  // the width and height of the bob
  146.         int width_fill;     // internal, used to force 8*x wide surfaces
  147.         int bpp;            // bits per pixel
  148.         int counter_1;      // general counters
  149.         int counter_2;
  150.         int max_count_1;    // general threshold values;
  151.         int max_count_2;
  152.         int varsI[16];      // stack of 16 integers
  153.         float varsF[16];    // stack of 16 floats
  154.         int curr_frame;     // current animation frame
  155.         int num_frames;     // total number of animation frames
  156.         int curr_animation; // index of current animation
  157.         int anim_counter;   // used to time animation transitions
  158.         int anim_index;     // animation element index
  159.         int anim_count_max; // number of cycles before animation
  160.         int *animations[MAX_BOB_ANIMATIONS]; // animation sequences
  161.  
  162.         LPDIRECTDRAWSURFACE4 images[MAX_BOB_FRAMES]; // the bitmap images DD surfaces
  163.  
  164.         } BOB, *BOB_PTR;
  165.  
  166. // the simple bitmap image
  167. typedef struct BITMAP_IMAGE_TYP
  168.         {
  169.         int state;          // state of bitmap
  170.         int attr;           // attributes of bitmap
  171.         int x,y;            // position of bitmap
  172.         int width, height;  // size of bitmap
  173.         int num_bytes;      // total bytes of bitmap
  174.         int bpp;            // bits per pixel
  175.         UCHAR *buffer;      // pixels of bitmap
  176.  
  177.         } BITMAP_IMAGE, *BITMAP_IMAGE_PTR;
  178.  
  179. // blinking light structure
  180. typedef struct BLINKER_TYP
  181.                {
  182.                // user sets these
  183.                int color_index;         // index of color to blink
  184.                PALETTEENTRY on_color;   // RGB value of "on" color
  185.                PALETTEENTRY off_color;  // RGB value of "off" color
  186.                int on_time;             // number of frames to keep "on" 
  187.                int off_time;            // number of frames to keep "off"
  188.  
  189.                // internal member
  190.                int counter;             // counter for state transitions
  191.                int state;               // state of light, -1 off, 1 on, 0 dead
  192.                } BLINKER, *BLINKER_PTR;
  193.  
  194. // a 2D vertex
  195. typedef struct VERTEX2DI_TYP
  196.         {
  197.         int x,y; // the vertex
  198.         } VERTEX2DI, *VERTEX2DI_PTR;
  199.  
  200. // a 2D vertex
  201. typedef struct VERTEX2DF_TYP
  202.         {
  203.         float x,y; // the vertex
  204.         } VERTEX2DF, *VERTEX2DF_PTR;
  205.  
  206.  
  207. // a 2D polygon
  208. typedef struct POLYGON2D_TYP
  209.         {
  210.         int state;        // state of polygon
  211.         int num_verts;    // number of vertices
  212.         int x0,y0;        // position of center of polygon  
  213.         int xv,yv;        // initial velocity
  214.         DWORD color;      // could be index or PALETTENTRY
  215.         VERTEX2DF *vlist; // pointer to vertex list
  216.  
  217.         } POLYGON2D, *POLYGON2D_PTR;
  218.  
  219.  
  220. // matrix defines
  221. typedef struct MATRIX3X3_TYP
  222.         {
  223.         float M[3][3]; // data storage
  224.         } MATRIX3X3, *MATRIX3X3_PTR;
  225.  
  226. typedef struct MATRIX1X3_TYP
  227.         {
  228.         float M[3]; // data storage
  229.         } MATRIX1X3, *MATRIX1X3_PTR;
  230.  
  231. typedef struct MATRIX3X2_TYP
  232.         {
  233.         float M[3][2]; // data storage
  234.         } MATRIX3X2, *MATRIX3X2_PTR;
  235.  
  236. typedef struct MATRIX1X2_TYP
  237.         {
  238.         float M[2]; // data storage
  239.         } MATRIX1X2, *MATRIX1X2_PTR;
  240.  
  241.  
  242. // PROTOTYPES /////////////////////////////////////////////
  243.  
  244. // DirectDraw functions
  245. int DDraw_Init(int width, int height, int bpp, int windowed=0);
  246. int DDraw_Shutdown(void);
  247. LPDIRECTDRAWCLIPPER DDraw_Attach_Clipper(LPDIRECTDRAWSURFACE4 lpdds, int num_rects, LPRECT clip_list);
  248. LPDIRECTDRAWSURFACE4 DDraw_Create_Surface(int width, int height, int mem_flags=0, USHORT color_key_value=0);
  249.  
  250. int DDraw_Flip(void);
  251. int DDraw_Wait_For_Vsync(void);
  252. int DDraw_Fill_Surface(LPDIRECTDRAWSURFACE4 lpdds, USHORT color, RECT *client=NULL);
  253. UCHAR *DDraw_Lock_Surface(LPDIRECTDRAWSURFACE4 lpdds,int *lpitch);
  254. int DDraw_Unlock_Surface(LPDIRECTDRAWSURFACE4 lpdds);
  255. UCHAR *DDraw_Lock_Primary_Surface(void);
  256. int DDraw_Unlock_Primary_Surface(void);
  257. UCHAR *DDraw_Lock_Back_Surface(void);
  258. int DDraw_Unlock_Back_Surface(void);
  259.  
  260. // BOB functions
  261. int Create_BOB(BOB_PTR bob,int x, int y,int width, int height,int num_frames,int attr,int mem_flags=0, USHORT color_key_value=0, int bpp=8);              
  262. int Clone_BOB(BOB_PTR source, BOB_PTR dest);
  263. int Destroy_BOB(BOB_PTR bob);
  264. int Draw_BOB(BOB_PTR bob, LPDIRECTDRAWSURFACE4 dest);
  265. int Draw_Scaled_BOB(BOB_PTR bob, int swidth, int sheight,LPDIRECTDRAWSURFACE4 dest);
  266. int Draw_BOB16(BOB_PTR bob, LPDIRECTDRAWSURFACE4 dest);
  267. int Draw_Scaled_BOB16(BOB_PTR bob, int swidth, int sheight,LPDIRECTDRAWSURFACE4 dest);
  268.  
  269. int Load_Frame_BOB(BOB_PTR bob, BITMAP_FILE_PTR bitmap, int frame, int cx,int cy,int mode);              
  270. int Load_Frame_BOB16(BOB_PTR bob, BITMAP_FILE_PTR bitmap, int frame, int cx,int cy,int mode);  
  271. int Animate_BOB(BOB_PTR bob);
  272. int Move_BOB(BOB_PTR bob);
  273. int Load_Animation_BOB(BOB_PTR bob, int anim_index, int num_frames, int *sequence);
  274. int Set_Pos_BOB(BOB_PTR bob, int x, int y);
  275. int Set_Vel_BOB(BOB_PTR bob,int xv, int yv);
  276. int Set_Anim_Speed_BOB(BOB_PTR bob,int speed);
  277. int Set_Animation_BOB(BOB_PTR bob, int anim_index);
  278. int Hide_BOB(BOB_PTR bob);
  279. int Show_BOB(BOB_PTR bob);
  280. int Collision_BOBS(BOB_PTR bob1, BOB_PTR bob2);
  281.  
  282.  
  283. // general utility functions
  284. DWORD Get_Clock(void);
  285. DWORD Start_Clock(void);
  286. DWORD Wait_Clock(DWORD count);
  287.  
  288. int Collision_Test(int x1, int y1, int w1, int h1, 
  289.                    int x2, int y2, int w2, int h2); 
  290.  
  291. int Color_Scan(int x1, int y1, int x2, int y2, 
  292.                UCHAR scan_start, UCHAR scan_end, 
  293.                UCHAR *scan_buffer, int scan_lpitch);
  294.  
  295. int Color_Scan16(int x1, int y1, int x2, int y2, 
  296.                   USHORT scan_start, USHORT scan_end, 
  297.                   UCHAR *scan_buffer, int scan_lpitch);
  298.  
  299. // graphics functions
  300. int Draw_Clip_Line(int x0,int y0, int x1, int y1, int color,UCHAR *dest_buffer, int lpitch);
  301. int Draw_Clip_Line16(int x0,int y0, int x1, int y1, int color,UCHAR *dest_buffer, int lpitch);
  302. int Clip_Line(int &x1,int &y1,int &x2, int &y2);
  303. int Draw_Line(int xo, int yo, int x1,int y1, int color,UCHAR *vb_start,int lpitch);
  304. int Draw_Line16(int xo, int yo, int x1,int y1, int color,UCHAR *vb_start,int lpitch);
  305. inline int Draw_Pixel(int x, int y,int color,UCHAR *video_buffer, int lpitch);
  306. int Draw_Rectangle(int x1, int y1, int x2, int y2, int color,LPDIRECTDRAWSURFACE4 lpdds);
  307. void HLine(int x1,int x2,int y,int color, UCHAR *vbuffer, int lpitch);
  308. void VLine(int y1,int y2,int x,int color, UCHAR *vbuffer, int lpitch);
  309. void Screen_Transitions(int effect, UCHAR *vbuffer, int lpitch);
  310. int Draw_Pixel(int x, int y,int color,UCHAR *video_buffer, int lpitch);
  311. int Draw_Pixel16(int x, int y,int color,UCHAR *video_buffer, int lpitch);
  312.  
  313. // palette functions
  314. int Set_Palette_Entry(int color_index, LPPALETTEENTRY color);
  315. int Get_Palette_Entry(int color_index, LPPALETTEENTRY color);
  316. int Load_Palette_From_File(char *filename, LPPALETTEENTRY palette);
  317. int Save_Palette_To_File(char *filename, LPPALETTEENTRY palette);
  318. int Save_Palette(LPPALETTEENTRY sav_palette);
  319. int Set_Palette(LPPALETTEENTRY set_palette);
  320. int Rotate_Colors(int start_index, int end_index);
  321. int Blink_Colors(int command, BLINKER_PTR new_light, int id);
  322.  
  323. // simple bitmap image functions
  324. int Create_Bitmap(BITMAP_IMAGE_PTR image, int x, int y, int width, int height, int bpp=8);
  325. int Destroy_Bitmap(BITMAP_IMAGE_PTR image);
  326. int Draw_Bitmap(BITMAP_IMAGE_PTR source_bitmap,UCHAR *dest_buffer, int lpitch, int transparent);
  327. int Draw_Bitmap16(BITMAP_IMAGE_PTR source_bitmap,UCHAR *dest_buffer, int lpitch, int transparent);
  328. int Load_Image_Bitmap(BITMAP_IMAGE_PTR image,BITMAP_FILE_PTR bitmap,int cx,int cy,int mode);  
  329. int Load_Image_Bitmap16(BITMAP_IMAGE_PTR image,BITMAP_FILE_PTR bitmap,int cx,int cy,int mode);               
  330. int Scroll_Bitmap(void); // ni
  331. int Copy_Bitmap(void); // ni
  332. int Flip_Bitmap(UCHAR *image, int bytes_per_line, int height);
  333.  
  334. // bitmap file functions
  335. int Load_Bitmap_File(BITMAP_FILE_PTR bitmap, char *filename);
  336. int Unload_Bitmap_File(BITMAP_FILE_PTR bitmap);
  337.  
  338. // gdi functions
  339. int Draw_Text_GDI(char *text, int x,int y,COLORREF color, LPDIRECTDRAWSURFACE4 lpdds);
  340. int Draw_Text_GDI(char *text, int x,int y,int color, LPDIRECTDRAWSURFACE4 lpdds);
  341.  
  342. // error functions
  343. int Open_Error_File(char *filename);
  344. int Close_Error_File(void);
  345. int Write_Error(char *string, ...);
  346.  
  347. // 2d 8-bit, 16-bit triangle rendering
  348. void Draw_Top_Tri(int x1,int y1,int x2,int y2, int x3,int y3,int color,UCHAR *dest_buffer, int mempitch);
  349.  
  350. void Draw_Bottom_Tri(int x1,int y1, int x2,int y2, int x3,int y3,int color,UCHAR *dest_buffer, int mempitch);
  351.  
  352. void Draw_Top_Tri16(int x1,int y1,int x2,int y2, int x3,int y3,int color,UCHAR *dest_buffer, int mempitch);
  353.  
  354. void Draw_Bottom_Tri16(int x1,int y1, int x2,int y2, int x3,int y3,int color,UCHAR *dest_buffer, int mempitch);
  355.  
  356. void Draw_Top_TriFP(int x1,int y1,int x2,int y2, int x3,int y3,int color,UCHAR *dest_buffer, int mempitch);
  357.  
  358. void Draw_Bottom_TriFP(int x1,int y1, int x2,int y2, int x3,int y3,int color,UCHAR *dest_buffer, int mempitch);
  359.  
  360. void Draw_Triangle_2D(int x1,int y1,int x2,int y2,int x3,int y3,
  361.                       int color,UCHAR *dest_buffer, int mempitch);
  362.  
  363. void Draw_Triangle_2D16(int x1,int y1,int x2,int y2,int x3,int y3,
  364.                         int color,UCHAR *dest_buffer, int mempitch);
  365.  
  366. void Draw_TriangleFP_2D(int x1,int y1,int x2,int y2,int x3,int y3,
  367.                         int color,UCHAR *dest_buffer, int mempitch);
  368.  
  369. inline void Draw_QuadFP_2D(int x0,int y0,int x1,int y1,
  370.                            int x2,int y2,int x3, int y3,
  371.                            int color,UCHAR *dest_buffer, int mempitch);
  372.  
  373.  
  374. // general 2D 8-bit, 16-bit polygon rendering and transforming functions
  375. void Draw_Filled_Polygon2D(POLYGON2D_PTR poly, UCHAR *vbuffer, int mempitch);
  376. void Draw_Filled_Polygon2D16(POLYGON2D_PTR poly, UCHAR *vbuffer, int mempitch);
  377. int Translate_Polygon2D(POLYGON2D_PTR poly, int dx, int dy);
  378. int Rotate_Polygon2D(POLYGON2D_PTR poly, int theta);
  379. int Scale_Polygon2D(POLYGON2D_PTR poly, float sx, float sy);
  380. void Build_Sin_Cos_Tables(void);
  381. int Translate_Polygon2D_Mat(POLYGON2D_PTR poly, int dx, int dy);
  382. int Rotate_Polygon2D_Mat(POLYGON2D_PTR poly, int theta);
  383. int Scale_Polygon2D_Mat(POLYGON2D_PTR poly, float sx, float sy);
  384. int Draw_Polygon2D(POLYGON2D_PTR poly, UCHAR *vbuffer, int lpitch);
  385. int Draw_Polygon2D16(POLYGON2D_PTR poly, UCHAR *vbuffer, int lpitch);
  386.  
  387. // math functions
  388. int Fast_Distance_2D(int x, int y);
  389. float Fast_Distance_3D(float x, float y, float z);
  390.  
  391. // collision detection functions
  392. int Find_Bounding_Box_Poly2D(POLYGON2D_PTR poly, 
  393.                              float &min_x, float &max_x, 
  394.                              float &min_y, float &max_y);
  395.  
  396. int Mat_Mul1X2_3X2(MATRIX1X2_PTR ma, 
  397.                    MATRIX3X2_PTR mb,
  398.                    MATRIX1X2_PTR mprod);
  399.  
  400. int Mat_Mul1X3_3X3(MATRIX1X3_PTR ma, 
  401.                    MATRIX3X3_PTR mb,
  402.                    MATRIX1X3_PTR mprod);
  403.  
  404. int Mat_Mul3X3(MATRIX3X3_PTR ma, 
  405.                MATRIX3X3_PTR mb,
  406.                MATRIX3X3_PTR mprod);
  407.  
  408. inline int Mat_Init_3X2(MATRIX3X2_PTR ma, 
  409.                         float m00, float m01,
  410.                         float m10, float m11,
  411.                         float m20, float m21);
  412.  
  413.  
  414. // memory manipulation functions
  415. inline void Mem_Set_WORD(void *dest, USHORT data, int count);
  416. inline void Mem_Set_QUAD(void *dest, UINT   data, int count);
  417.  
  418.  
  419. // GLOBALS ////////////////////////////////////////////////
  420.  
  421. extern FILE *fp_error;                           // general error file
  422.  
  423. // notice that interface 4.0 is used on a number of interfaces
  424. extern LPDIRECTDRAW4        lpdd;                 // dd object
  425. extern LPDIRECTDRAWSURFACE4 lpddsprimary;         // dd primary surface
  426. extern LPDIRECTDRAWSURFACE4 lpddsback;            // dd back surface
  427. extern LPDIRECTDRAWPALETTE  lpddpal;              // a pointer to the created dd palette
  428. extern LPDIRECTDRAWCLIPPER  lpddclipper;          // dd clipper for back surface
  429. extern LPDIRECTDRAWCLIPPER  lpddclipperwin;       // dd clipper for window
  430. extern PALETTEENTRY         palette[256];         // color palette
  431. extern PALETTEENTRY         save_palette[256];    // used to save palettes
  432. extern DDSURFACEDESC2       ddsd;                 // a direct draw surface description struct
  433. extern DDBLTFX              ddbltfx;              // used to fill
  434. extern DDSCAPS2             ddscaps;              // a direct draw surface capabilities struct
  435. extern HRESULT              ddrval;               // result back from dd calls
  436. extern UCHAR                *primary_buffer;      // primary video buffer
  437. extern UCHAR                *back_buffer;         // secondary back buffer
  438. extern int                  primary_lpitch;       // memory line pitch
  439. extern int                  back_lpitch;          // memory line pitch
  440. extern BITMAP_FILE          bitmap8bit;           // a 8 bit bitmap file
  441. extern BITMAP_FILE          bitmap16bit;          // a 16 bit bitmap file
  442. extern BITMAP_FILE          bitmap24bit;          // a 24 bit bitmap file
  443.  
  444.  
  445. extern DWORD                start_clock_count;    // used for timing
  446. extern int                  windowed_mode;        // tracks if dd is windowed or not
  447.  
  448. // these defined the general clipping rectangle for software clipping
  449. extern int min_clip_x,                             // clipping rectangle 
  450.            max_clip_x,                  
  451.            min_clip_y,     
  452.            max_clip_y;                  
  453.  
  454. // these are overwritten globally by DD_Init()
  455. extern int screen_width,                            // width of screen
  456.            screen_height,                           // height of screen
  457.            screen_bpp,                              // bits per pixel 
  458.            screen_windowed;                         // is this a windowed app?   
  459.  
  460.  
  461. extern int dd_pixel_format;                         // default pixel format
  462.  
  463. extern int window_client_x0;   // used to track the starting (x,y) client area for
  464. extern int window_client_y0;   // for windowed mode directdraw operations
  465.  
  466. // storage for our lookup tables
  467. extern float cos_look[360];
  468. extern float sin_look[360];
  469.  
  470.  
  471. #endif
  472.  
  473.  
  474.